package com.atguigu.tingshu;

import com.atguigu.tingshu.common.constant.RedisConstant;
import org.mybatis.spring.annotation.MapperScan;
import org.redisson.api.RBloomFilter;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;

/**
 * 服务相册应用程序
 *
 * @author ym
 * @date 2025/06/06
 */
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
@MapperScan("com.atguigu.tingshu.album.mapper")

public class ServiceAlbumApplication implements CommandLineRunner {

    /**
     * 主要
     *
     * @param args args
     */
    public static void main(String[] args) {
        SpringApplication.run(ServiceAlbumApplication.class, args);
    }

    /**
     * 客户编辑
     */

    @Autowired
    private RedissonClient redissonClient;

    /**
     * 跑
     *
     * @param args args
     * @throws Exception 无效
     */
    @Override
    public void run(String... args) throws Exception {
        System.out.println("布隆过滤器初始化");
        RBloomFilter<Long> bloomFilter = redissonClient.getBloomFilter(RedisConstant.ALBUM_BLOOM_FILTER);
        //2.调用初始化方法 p1:数据规模  p2:误判率
        bloomFilter.tryInit(500000L, 0.03);//初始化步骤

    }
}
